﻿using System.Web.Mvc;
using System.Web.Routing;
using Comdiv.Application;
using Comdiv.Extensibility;
using Comdiv.Extensibility.Boo;
using Comdiv.Inversion;
using MvcContrib.Comdiv.Framework;
using MvcContrib.ViewFactories;

namespace wikiviewer{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            ControllerBuilder.Current.SetControllerFactory(new InversionControllerFactory { Container = myapp.Container});
            ((WindsoreInversionContainer)myapp.Container).Container.LoadDefaultXml();
            myapp.Container.set<IDefaultScriptMachine, ClassicDefaultApplicationScriptMachine>();
            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new BrailViewFactory());
            foreach (var initializer in myapp.Container.all<IContainerInitializer>())
            {
                initializer.Apply(myapp.Container);
            }
            foreach (var router in myapp.Container.all<IRouteStartup>())
            {
                router.RegisterRouts(RouteTable.Routes);
            }
        }
    }
}